load('pe22.dat');

scopes = [];
for(var i=1; i<=26; i++) {
    scopes[String.fromCharCode(64+i)] = i
}

function getScope(name) {
    var names = name.split("");
    var sum = 0;
    for(var i=0; i<names.length; i++) {
        sum += scopes[names[i]];        
    }
    return sum;
}

function pe22(){
    names = names.sort();
    var sum = 0;
    for(var i=0; i<names.length; i++) {
        sum += getScope(names[i]) + i;        
    }
    return sum;
}

print(pe22());
